package com.iron.common.log.event;

import com.iron.sfm.api.entity.SysLog;
import com.iron.sfm.api.feign.SysLogFeign;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

/**
 * 异步监听日志事件
 *
 * @author YT
 * @date 2019-06-27
 */
@Slf4j
@AllArgsConstructor
public class SysLogListener {

    private final SysLogFeign sysLogFeign;

    @Async
    @Order
    @EventListener(SysLogEvent.class)
    public void saveSysLog(SysLogEvent event) {
        SysLog sysLog = (SysLog) event.getSource();
        sysLogFeign.saveLog(sysLog);
    }
}
